/**
 * ParentedObject.as
 * Andy Jiang   
 * Fusion Digital Shanghai Co,Ltd. All Rights Reserved.
 * version 0.1
 */ 

package jiezi.ui
{
	import flash.events.Event;
	import jiezi.log.Logger
	
	public class ParentedObject extends UIObject
	{
		public static const ATTACH:String			= "attach";
		
		protected var mChildren:Array;
		protected var mParent:ParentedObject;

		public function ParentedObject(name:String)
		{
			super(name);
			this.mParent = null;
			this.mChildren = new Array()
		}

		public function set parent(parent:ParentedObject):void
		{
			this.mParent = parent;
		}
		public function get parent():ParentedObject
		{
			return this.mParent;
		}
	
		public function addChild(child:ParentedObject):void
		{
			if ( child.parent )
			{
				// already has child, return
				return
			}
			this.mChildren.push(child)
			child.parent = this
			child.dispatchEvent(new Event(ATTACH))
		}
  }
}
